﻿using AspectCore.Extensions.DependencyInjection;
using AspectCore.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace AiQiuQuan.Sport.Core
{
    /// <summary>
    /// AspectExtensions
    /// </summary>
    public static class AspectExtensions
    {
        /// <summary>
        /// 为服务添加ASPECT
        /// </summary>
        public static IServiceCollection AddAspectService(this IServiceCollection services)
        {
            services.ConfigureDynamicProxy(config =>
            {
                //config.Interceptors.AddTyped<ITransientDependency>(Predicates.ForNameSpace("Handday.Erp.Transfer.Subscriber"));
            });

            return services;
        }

        /// <summary>
        /// UseAspect
        /// </summary>
        public static IHostBuilder UseAspect(this IHostBuilder hostBuilder)
        {
            return hostBuilder.UseDynamicProxy();
        }
    }
}
